package com.ruoyi.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysADevelopersList;
import com.ruoyi.system.service.ISysADevelopersListService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 开发商管理Controller
 * 
 * @author H
 * @date 2021-11-09
 */
@Controller
@RequestMapping("/system/developers")
public class SysADevelopersListController extends BaseController
{
    private String prefix = "system/developers";

    @Autowired
    private ISysADevelopersListService sysADevelopersListService;

    @RequiresPermissions("system:developers:view")
    @GetMapping()
    public String developers()
    {
        return prefix + "/developers";
    }

    /**
     * 查询开发商管理列表
     */
    @RequiresPermissions("system:developers:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(SysADevelopersList sysADevelopersList)
    {
        startPage();
        List<SysADevelopersList> list = sysADevelopersListService.selectSysADevelopersListList(sysADevelopersList);
        return getDataTable(list);
    }

    /**
     * 导出开发商管理列表
     */
    @RequiresPermissions("system:developers:export")
    @Log(title = "开发商管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(SysADevelopersList sysADevelopersList)
    {
        List<SysADevelopersList> list = sysADevelopersListService.selectSysADevelopersListList(sysADevelopersList);
        ExcelUtil<SysADevelopersList> util = new ExcelUtil<SysADevelopersList>(SysADevelopersList.class);
        return util.exportExcel(list, "开发商管理数据");
    }

    /**
     * 新增开发商管理
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存开发商管理
     */
    @RequiresPermissions("system:developers:add")
    @Log(title = "开发商管理", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(SysADevelopersList sysADevelopersList)
    {
        return toAjax(sysADevelopersListService.insertSysADevelopersList(sysADevelopersList));
    }

    /**
     * 修改开发商管理
     */
    @GetMapping("/edit/{developersId}")
    public String edit(@PathVariable("developersId") String developersId, ModelMap mmap)
    {
        SysADevelopersList sysADevelopersList = sysADevelopersListService.selectSysADevelopersListByDevelopersId(developersId);
        mmap.put("sysADevelopersList", sysADevelopersList);
        return prefix + "/edit";
    }

    /**
     * 修改保存开发商管理
     */
    @RequiresPermissions("system:developers:edit")
    @Log(title = "开发商管理", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(SysADevelopersList sysADevelopersList)
    {
        return toAjax(sysADevelopersListService.updateSysADevelopersList(sysADevelopersList));
    }

    /**
     * 删除开发商管理
     */
    @RequiresPermissions("system:developers:remove")
    @Log(title = "开发商管理", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(sysADevelopersListService.deleteSysADevelopersListByDevelopersIds(ids));
    }
}
